#include <iostream>
using namespace std;

class Person 
{

    public:
       Person(){
         cout<< "Person()"<<endl;
       }
      virtual ~Person(){
         cout<< "~Person()"<<endl;
       }
      virtual void work() = 0;
      void setName(const string &name){
           this->name = name;  
       }
       string getName() const{
           return name;
       }

  protected:
    string name;

       
};

class Student: virtual public Person
{

    public:
       Student(){
        cout<< "Student()"<<endl;
       }
       virtual ~Student(){
        cout << "~Student()"<<endl;
       }
       virtual void work(){
           cout <<"Student()::work()"<<endl;
       }
       
    
};


int main(){
   // 抽象类不能实例化
    // 如果在派生类中不实现纯虚函数，派生类也将是抽象类
    Person *stu = new Student;
    stu->work();
    stu->setName("zjm");
    cout << "name: " << stu->getName() << endl;
    delete stu;
    stu = nullptr;
    return 0;
    
    
}